<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue.js + axios + api</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>

    <script src="https://cdn.staticfile.org/vue/2.7.0/vue.min.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <link href="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<h1>显示列表</h1>
<div id="vue_user">
    <!--    {{info}}-->

    <!--            <li v-for="u in info">-->
    <!--                {{u.username}}+{{u.password}}+{{u._links.self.href.split("/")[4]}}-->
    <!--            </li>-->

    <!--</div>-->
    <table class="table">
        <thead>
        <tr>
            <th>id</th>
            <th>name</th>
            <th>password</th>
        </tr>
        </thead>
        <tbody>
        <tr v-for="u in info">
            <td>{{u._links.self.href.split("/")[4]}}</td>
            <td>t{{u.username}}</td>
            <td>{{u.password}}</td>
        </tr>
        </tbody>
    </table>
</div>
    <script type="text/javascript">
        var vm = new Vue({
            el: '#vue_user',
            data: {},
            methods: {},
            data() {
                return {
                    info: null
                }
            },
            mounted() {
                axios
                    .get('http://localhost:7006/customers')
                    .then(response => (this.info = response.data._embedded.customers))
                    .catch(function (error) { // 请求失败处理
                        console.log(error);
                    });
            }
        })

    </script>
</body>
</html>